package wusiyuan.dao.impl;

import java.sql.SQLException;
import java.util.List;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import entity.User;
import entity.User_Inf;
import util.C3P0Util;
import wusiyuan.dao.ChangePasswordDao;

public class ChangePasswordDaoImpl implements ChangePasswordDao{

	@Override
	public User_Inf getUserInfo(String username) {
		QueryRunner qr = new QueryRunner(C3P0Util.getDataSource());		
		String sql = "select * from user_inf where username = ? ";
		User_Inf user =null;
		try {
			user=qr.query(sql, username, new BeanHandler<User_Inf>(User_Inf.class));
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return user;
	}

	@Override
	public List<User> getHistoryPassword(String username) {
		QueryRunner qr = new QueryRunner(C3P0Util.getDataSource());		
		String sql = "select * from user_login_log where username = ? ";
		List<User> list=null;
		
		try {
			list=qr.query(sql, username,new BeanListHandler<User>(User.class));
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}

}
